var select = document.getElementsByName('province')
select[0].addEventListener('change', function () {
    setTimeout(function () {
        var a = document.getElementById('change_id_province')
        p = a['href'].substring(51, 53)
        var url = 'http://127.0.0.1:8000/ch/citys/' + p
        $.ajax({
            url: url, success: function (res) {
                city = $('#id_city').empty()
                op = "<option selected>" + "---------" + "</option>"
                for (var i = 0; i < res.length; i++) {
                    cit1 = '<option value="' + res[i].id + '">' + res[i].name + '</option>'
                    op += cit1
                }
                city.html(op)
            }
        });
    }, 300)

})
var city2 = document.getElementsByName('city')
city2[0].addEventListener('change', function () {
    setTimeout(function () {
        var a = document.getElementById('change_id_city')
        console.log(a['href'])
        pa = a['href'].substring(47,50)
        console.log(pa)
        var url = 'http://127.0.0.1:8000/ch/countrys/' + pa
        $.ajax({
            url: url, success: function (res) {
                country = $('#id_country').empty()
                op = "<option selected>" + "---------" + "</option>"
                for (var i = 0; i < res.length; i++) {
                    cit1 = '<option value="' + res[i].id + '">' + res[i].name + '</option>'
                    op += cit1
                }
                country.html(op)
            }
        });
    }, 300)

})
